﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Download_Download : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string strTempFolder = ConfigurationSettings.AppSettings["TemplateFolder"];
            string strExportFolder = ConfigurationSettings.AppSettings["ExportFolder"];
            string strType = "";
            string strFileNameHeader = "";
            string strFileNameOld = "";
            if (Request.QueryString["type"] != null)
            {
                strType = Request.QueryString["type"].ToString();
                switch (strType)
                {

                    case "BaoCaoNguoiDung":
                        strFileNameHeader = "BaoCaoNguoiDung" + DateTime.Now.ToString("ddMMyyyy") + ".xlsx";
                        strFileNameOld = "BaoCaoNguoiDung.xlsx";
                        break;
                }
            }
            Response.Clear();
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("content-disposition", "attachment;filename=" + strFileNameHeader);
            Response.TransmitFile(Server.MapPath(ResolveUrl("~/") + strExportFolder + "/" + strFileNameOld));
            Response.Flush();
            Response.End();
        }
    }
}